from functools import lru_cache

from pydantic import RedisDsn
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    app_name: str = "Awesome API"
    admin_email: str
    items_per_user: int = 50
    port: int

    """应用配置"""
    app_host: str
    app_version: str
    app_port: int = 8080
    app_env: str = "dev"
    app_debug: bool = False
    """jwt配置"""
    jwt_enable: bool = False
    jwt_secret_key: str = "12345789@98765431"
    jwt_algorithm: str = "HS256"
    jwt_expired: int = 30
    jwt_iss: str = "猿码记"
    jwt_no_check_uris: str = ""
    """数据库配置"""
    db_host: str
    db_port: int
    db_user: str
    db_password: str
    db_database: str
    """redis配置"""
    redis_dsn: RedisDsn = None

    class Config:
        env_file = ".env"


@lru_cache
def get_settings():
    return Settings()


config = get_settings()
